<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="commontaglib"%>
<%
String path = request.getContextPath();

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
 
<html>
  <head>
    <link rel="stylesheet" href="<%=path%>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=path%>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<%=path%>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/jquery-ui.custom.min.js"></script>  
    <script type="text/javascript" src="<%=path%>/js/i18n/grid.locale-cn.js"></script> 
    <script type="text/javascript" src="<%=path%>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
    <style>
html, body {
	margin: 0;			 
	padding: 0;
	 
    font-size: 85%;
}
</style>
    <script type="text/javascript"> 
    
  $(function(){ 
    $("#xinz").button(); 
    $("#chax").button();
    $("#shanc").button();
    $("#tib").button();
    $("#daoc").button();
    $("#fuz").button(); 
    loadTab();
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    
 });
    
    function loadTab(){  
    $("#myTab").jqGrid({      
    url:'htbcxyJqgrid.action',   
    datatype: 'json',
    mtype: 'post',         
   	colNames:['合同编号', '补充协议开始时间', '补充协议结束时间','协议状态'],
   	colModel:[   		
   		{name:'hetlrbh',index:'hetlrbh', width:200},
   		{name:'bucxykssj',index:'bucxykssj', width:200},
   		{name:'bucxyjssj',index:'bucxyjssj', width:200 },   		
   		{name:'xyzt',index:'xyzt', sortable:false}		
   				
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'xieybh'
         },    	
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager13',
   	rownumbers: true,   	 
    viewrecords: true,
    multiselect: true,    
	caption: "合同列表"	,
		ondblClickRow: function(rowid){
	  // var id = $("#myTab").jqGrid('getGridParam', 'selrow');
       // alert(rowid);
        openwindow('<%=path %>/htgl/htbcxyInfo.action?xybh='+rowid); 
	}
  });
  }
   function openwindow(url){
    var sheight = screen.height-30;
    var swidth = screen.width-1;
    var winoption ="height="+sheight+"px,width="+ swidth +"px,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=yes,status=yes";
    var result=window.open(url,"newwindow",winoption);
    if(result ==1) window.location.reload(); 
    return result;  
}
  
  function search(){   
  var formdata = $("#form1").serialize();  
  $("#myTab").jqGrid('setGridParam',{url:'htbcxyJqgrid.action?'+formdata,mtype:'post',page:1}).trigger("reloadGrid"); 
}

function removeRow() {	
	var s = $("#myTab").jqGrid('getGridParam','selarrrow');
	var url = "<%=path%>/htgl/removeHtbcxyInfo.action?xybh="+s;
	$( "#dialog-confirm" ).dialog({
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
					$.post(url, function(data) {
                    //alert(data); 
                    location.reload();                    
                   });
                   $( this ).dialog( "close" ); 
                    
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});

}


function submitRow() {
	var s = $("#myTab").jqGrid('getGridParam','selarrrow');
	if (s == "") {
        alert("请先选择合同，再点击提交！");
        return;
    }
    
	var url = "<%=path%>/htgl/submitHtbcxyInfo.action?xieybh="+s;
	$( "#dialog-confirm1" ).dialog({
			resizable: false,
			height:140,
			modal: true,
			buttons: {
				"确认": function() {
				    
					$.post(url, function(data) {					
                    var json =eval('(' + data + ')');
					   if(json.result==1){					   
					   alert("提交成功！");
					   search();
					   }else{					  
					   alert("提交失败！"+json.msg);
					   }   
                   });                  
                   $( this ).dialog( "close" );
				},
				"返回": function() {
					$( this ).dialog( "close" );
				}
			}
		});     
}

</script>  
  </head>
  
  <body>
    <div id="best1">
<h2><span>补充协议录入</span></h2>
<form id="form1" method="post">
<table id="list_search" cellpadding="0" cellspacing="0" border="0"> 
        <tr>
        	<td> 
            	合同编号: 
            </td>
            <td>
            	<input type="text" class="longtextbox" name="bean.AA" /> 
            </td>
            <td>补充协议时间:</td>
            <td><input id="datepicker" type="text" class="textbox" name="bean.BB" /> -- <input id="datepicker1" type="text" class="textbox" name="bean.CC" /></td>
        <td colspan="2" style="float:left"><input id="chax" type="button" value="查询" onclick="search();"/></td>      
       
        
        </tr>
        
  </table> 
  </form>
   <h3><span></span></h3>
    <table id="list_search" cellpadding="0" cellspacing="0" border="0">
    <tr>
		    <td align="left">
		    <input id="xinz" type="button" name="" value="新增"  onclick= "window.location.href='<%=path %>/htgl/htbcxyAdd.action',target='mainFrame'"/>&nbsp;&nbsp;
		    <input id="shanc" type="button"  value="删除" onclick="removeRow();" />&nbsp;&nbsp;	
		    <input id="tib" type="button" value="提报"  onclick="submitRow();"/>&nbsp;&nbsp;	    
		    <input id="daoc" type="hidden" value="导出Excel"  />&nbsp;&nbsp;
		    <input id="fuz" type="hidden" value="复制"  />&nbsp;&nbsp;		   
		    </td>
            
            
        </tr>
    </table>
    <table id="myTab" class="scroll" cellpadding="0" cellspacing="0"></table>  
   <div id="pager13" class="scroll"></div>  
   <div id="message" class="scroll"></div> 
   <div id="dialog-confirm" title="是否确认删除？"></div>
   <div id="dialog-confirm1" title="是否确认提交？"></div>
</div> 
  </body>
</html>
